/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tasks.ui.architecture;

import domain.UnitDTO;
import java.util.LinkedList;
import java.util.Set;
import javax.swing.AbstractListModel;

/**
 *
 * @author David
 */
public class UnitListModel extends AbstractListModel{
    
    private LinkedList<UnitDTO> units;
    
    public UnitListModel(Set<UnitDTO> units){
        this.units = new LinkedList<UnitDTO>(units);
    }

    @Override
    public int getSize() {
        return units.size();
    }

    @Override
    public Object getElementAt(int index) {
        return "<<" + units.get(index).getType().getName() + ">>: " + this.units.get(index).getName(); 
    }
    
    public UnitDTO getUnitAt(int index) {
        return this.units.get(index);
    }
    
    public int getIndexOfUnit(UnitDTO unit){
        return units.indexOf(unit);
    }
    
}
